<template>
    <div class="box">
        <div class="detBox">
            <el-row>
                <el-col :span="24">
                    <div class="grid-content bg-purple">
                        <div class="btitle">{{$t('perinf')}}</div>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <div class="bhead">{{$t('surname')}}</div>
                    </div>
                </el-col>
                <el-col :span="20">
                    <div class="grid-content bg-purple-light">
                        <input type="text" class="bbody" v-model="accountResult.firstName">
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <div class="bhead">{{$t('nme')}}</div>
                    </div>
                </el-col>
                <el-col :span="20">
                    <div class="grid-content bg-purple-light">
                        <input type="text" class="bbody" v-model="accountResult.secondName">
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <div class="bhead">{{$t('birday')}}</div>
                    </div>
                </el-col>
                <el-col :span="20">
                    <div class="grid-content bg-purple-light">
                        <input type="text" class="bbody" v-model="accountResult.birth">
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <div class="bhead">BVN</div>
                    </div>
                </el-col>
                <el-col :span="20">
                    <div class="grid-content bg-purple-light">
                        <input type="text" class="bbody" v-model="accountResult.bvn">
                    </div>
                </el-col>
            </el-row>
        </div>
        <el-button class="stayyy" type="primary" @click="showeditUser" v-preventReClick>{{$t('mdfy')}}</el-button>
        <el-dialog :title="$t('mdfy')" :visible.sync="aaaDialogVisible" width="30%" :modal-append-to-body="false">
            <span>{{$t('whetomod')}}</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="aaaDialogVisible = false" v-preventReClick>{{$t('cnl')}}</el-button>
                <el-button type="primary" @click="editUser" v-preventReClick>{{$t('cfm')}}</el-button>
            </span>
        </el-dialog>
  </div>
</template>

<script>
import {
    getaccountlist,
    editaccountlist
} from '@/libs/reqlist.js'
export default {
    data() {
        return {
            aaaDialogVisible: false,
            // 接收查询返回值
            accountResult: {},
            // 查询入参
            select: {
                merId: ''
            },
            name: ''
        }
    },
    methods: {
        getAccountInfo() {
            getaccountlist(JSON.stringify({ merId: this.select.merId })).then(res => {
                // 成功
                if (res.data.code === '000000') {
                    this.accountResult = res.data.data
                }
            })
        },
        showeditUser () {
            this.aaaDialogVisible = true
        },
        editUser () {
            delete this.accountResult.email
            delete this.accountResult.mobile
            this.accountResult.merId = this.select.merId
            if (this.accountResult.firstName !== '' && this.accountResult.secondName !== '' && this.accountResult.bvn !== '' && this.accountResult.birth !== '') {
                editaccountlist(this.accountResult).then(res => {
                    if (res.data.code === '000000') {
                        this.$message({
                            message: this.$t('modfunsuc'),
                            type: 'success'
                        })
                        this.aaaDialogVisible = false
                        this.getAccountInfo()
                    }
                })
            }
            if (this.accountResult.firstName === '' || this.accountResult.secondName === '' || this.accountResult.bvn === '' || this.accountResult.birth === '') {
                this.$message.error(this.$t('datacanbeempty'))
                this.aaaDialogVisible = false
                this.getAccountInfo()
            }
        }
    },
    mounted() {
          // 全局商户id
        this.select.merId = window.sessionStorage.getItem('merId')
        this.getAccountInfo()
    }
}
</script>

<style lang="less" scoped>
@import './accountInfo.less';
</style>
